{% extends "/home/steveswanson/webapps/django/myuwaterloo/templates/home.html" %}

{%block head%} {%endblock%}
{%block title%} {{classtitle|escape}} {%endblock%}

{%block content%}

{%for result in usercoursedata%}
	{{usercoursedata.user}}
{%endfor%}


{{form.errors}}

<div id="content" class="c clear_children">

	<div id="content_mainClassdisplay" class = "pc cc_tallest">
		{%for result in classinfo%}
			{%if result.description%}
				<div id="classDisplay">
					<!--If statement to get only the first matching item--> 
					<h2 id="encasing">
						<span>
							{{classtitle}} -  
							
							<img id="star_1" src="/media/images/grayStar1.png" onmouseover="javascript:starover(this)" onclick="javascript:starclick(this)" onmouseout="javascript:rating({{rating}})" >
							<img id="star_2" src="/media/images/grayStar1.png" onmouseover="javascript:starover(this)"  onclick="javascript:starclick(this)" onmouseout="javascript:rating({{rating}})">
							<img id="star_3" src="/media/images/grayStar1.png" onmouseover="javascript:starover(this)"  onclick="javascript:starclick(this)" onmouseout="javascript:rating({{rating}})">
							<img id="star_4" src="/media/images/grayStar1.png" onmouseover="javascript:starover(this)"  onclick="javascript:starclick(this)" onmouseout="javascript:rating({{rating}})">
							<img id="star_5" src="/media/images/grayStar1.png" onmouseover="javascript:starover(this)"  onclick="javascript:starclick(this)" onmouseout="javascript:rating({{rating}})"> 
							
							- Based on {{ratingcount|escape}} Ratings
							
							<form name="form1" action="." method="POST">
								<input name="rating" type="hidden" value="0" />
							</form> 
							
						</span>
					</h2>
					{%if user.is_authenticated%}
						{%if userRating %}
								<p>You rated this course a {{userRating|escape}}. Change your rating by rolling over the stars!</p>
						{%endif%}
					{%endif%}
				</div>
		
				<br>
		
				<div id="classDisplay">
					<h2 id="encasing">Description:</h2>
					<p >{{result.description}}</p>
				</div>
			
				<br>
			
				<div id="classDisplay">
					<h2 id="encasing">Requisites:</h2>
					<span id="h4req">Pre-Requisites:</span><p>{{result.prereq}}</p>
					<span id="h4req">Anti-Requisites:</span><p>{{result.antireq}}</p>
				</div>
				<br>
			{%endif%}
		{%endfor%}
	</div>	
	
	
	<div id="content_rating" class="sc">
		<div id="classDisplay">
		
			<h2 id="login">Additional Info</h2>

				
				<p id='addInfo'>Was it easy?</p>
				{{difficult}}
				<img id="difficult_1" src="/media/images/downthumbGray.png" onmouseout="javascript:downThumbOff(this)" onmouseover="javascript:downThumbOver(this)" onclick="javascript:downThumbDifficultClick(this)">
				<img id="difficult_2" src="/media/images/upthumbGray.png" onmouseout="javascript:upThumbOff(this)" onmouseover="javascript:upThumbOver(this)"  onclick="javascript:upThumbDifficultClick(this)">
				
				<form name="formd" action="." method="POST">
						<input name="difficult" type="hidden" value="0" />
				</form> 
				
				<br>
	
				
				<p id='addInfo'>Was it interesting?</p>
				{{interesting}}
				<img id="interesting_1" src="/media/images/downthumbGray.png" onmouseout="javascript:downThumbOff(this)" onmouseover="javascript:downThumbOver(this)" onclick="javascript:thumbInterestingClick(this)">
				<img id="interesting_2" src="/media/images/upthumbGray.png" onmouseout="javascript:upThumbOff(this)" onmouseover="javascript:upThumbOver(this)"  onclick="javascript:thumbInterestingClick(this)">
				
				<form name="formi" action="." method="POST">
						<input name="interesting" type="hidden" value="0" />
				</form> 
				
				<br>
				
				<p id='addInfo'>Light Workload?</p>
				{{heavyworkload}}
				<img id="heavyworkload_1" src="/media/images/downthumbGray.png" onmouseout="javascript:downThumbOff(this)" onmouseover="javascript:downThumbOver(this)" onclick="javascript:thumbHeavyworkloadClick(this)">
				<img id="heavyworkload_2" src="/media/images/upthumbGray.png" onmouseout="javascript:upThumbOff(this)" onmouseover="javascript:upThumbOver(this)"  onclick="javascript:thumbHeavyworkloadClick(this)">

				<form name="formh" action="." method="POST">
						<input name="heavyworkload" type="hidden" value="0" />
				</form> 				<br>
				
				<p id='addInfo'>Glad course was taken?</p>
				{{gladtook}}
				<img id="gladtook_1" src="/media/images/downthumbGray.png" onmouseout="javascript:downThumbOff(this)" onmouseover="javascript:downThumbOver(this)" onclick="javascript:downThumbGladtookClick(this)">
				<img id="gladtook_2" src="/media/images/upthumbGray.png" onmouseout="javascript:upThumbOff(this)" onmouseover="javascript:upThumbOver(this)"  onclick="javascript:upThumbGladtookClick(this)">
				
				<form name="formg" action="." method="POST">
						<input name="gladtook" type="hidden" value="0" />
				</form> 
				
				<br>

		</div>
		<br>
		
		
		
	</div>
</div>


{%if spring09info%}
<div id="classDisplay">
	<h2 id="encasing">Classes Scheduled for Spring 09</h2>
	<p>
		<table id="classSchedule" cellSpacing="1" align="center" cellPadding="1"  border="2" width="90%" >
			<tr style="font-weight:bold">
				<th width=14%>Section</th>
				<th>Professor</th>
				<th>RateMyProf Rating</th>
				<th>Location</th>
				<th>Scheduled Time</th>
				<th width=12%>Course ID</th>
			</tr>
			{%for result in spring09info%}
				<tr>
					<td>{{result.section}} </td>
					<td><a href={{result.profLink}} target="_blank">{{result.instructor}}</a> </td>
					<td>{{result.profRating}}</td>
					<td>{{result.building}}</td>
					<td>{{result.schedule}}</td>
					<td>{{result.courseid}}</td>
				</tr>
			{%endfor%}
		</table>
	</p>
</div>
{%endif%}


{%if fall09info%}
<br>
<div id="classDisplay">
	
	<h2 id="encasing">Classes Scheduled for Fall 09</h2>
	<p>
		<table id="classSchedule" cellSpacing="1" align="center" cellPadding="1"  border="2" width="90%" >
			<tr style="font-weight:bold">
				<th width=14%>Section</th>
				<th>Professor</th>
				<th>RateMyProf Rating</th>
				<th>Location</th>
				<th>Scheduled Time</th>
				<th width=12%>Course ID</th>
			</tr>
			{%for result in fall09info%}
				<tr>
					<td>{{result.section}} </td>
					{%if result.profLink %}
						<td><a href={{result.profLink}} target="_blank">{{result.instructor}}</a> </td>
					{%else%}
						<td>{{result.instructor}}</td>
					{%endif%}
					<td>{{result.profRating}}</td>
					<td>{{result.building}}</td>
					<td>{{result.schedule}}</td>
					<td>{{result.courseid}}</td>
				</tr>
			{%endfor%}
		</table>
	</p>
</div>
{%endif%}


{%if winter09info%}
<br>
<div id="classDisplay">
	<h2 id="encasing">Projected Schedule for Winter 10 (Based on W09)</h2>
	<p>
		<table id="classSchedule" cellSpacing="1" align="center" cellPadding="1"  border="2" width="90%" >
			<tr style="font-weight:bold">
				<th width=14%>Section</th>
				<th>Professor</th>
				<th>RateMyProf Rating</th>
				<th>Location</th>
				<th>Scheduled Time</th>
				<th width=12%>Course ID</th>
			</tr>
			{%for result in winter09info%}
				<tr>
					<td>{{result.section}} </td>
					<td><a href={{result.profLink}} target="_blank">{{result.instructor}}</a> </td>
					<td>{{result.profRating}}</td>
					<td>{{result.building}}</td>
					<td>{{result.schedule}}</td>
					<td>{{result.courseid}}</td>
				</tr>
			{%endfor%}
		</table>
	</p>
</div>
{%endif%}

<br>

{%if user.is_authenticated%}
<script type="text/javascript">

function starclick(obj) {
		
      var id = obj.id;
      var index = id.indexOf('_');
      var num = id.substring(index+1, id.length);
      document.form1.rating.value = num;
      document.form1.submit();

}



function starover(obj) {
      var id = obj.id;
      var index = id.indexOf('_');
      var num = id.substring(index+1, id.length);
	  
	  lightUP(num);
	    
}

function lightUP(index) {
	   
      for (i=1; i<6; i++) {
			
            var string = "star_"+i;
            var element = document.getElementById(string);
			
            if (i<= index) {
                  element.src = "/media/images/redStar.png";
            } 
			
			else {
                  element.src = "/media/images/grayStar1.png";
            }
			
			
      }

}

function rating(index) {
	   
      for (i=1; i<6; i++) {
			
            var string = "star_"+i;
            var element = document.getElementById(string);
			
            if (i<= index) {
                  element.src = "/media/images/redStar.png";
            } 
			
			else {
                  element.src = "/media/images/grayStar1.png";
            }
			
			
      }

}


function downThumbOff(obj){
var element =document.getElementById(obj.id);
element.src = "/media/images/downthumbGray.png";
}

function downThumbOver(obj){
var element =document.getElementById(obj.id);
element.src = "/media/images/downthumbRed.png";
}

function upThumbOff(obj){
var element =document.getElementById(obj.id);
element.src = "/media/images/upthumbGray.png";
}

function upThumbOver(obj){
var element =document.getElementById(obj.id);
element.src = "/media/images/upthumbGreen.png";
}

function downThumbGladtookClick(obj){
      document.formg.gladtook.value = 1;
      document.formg.submit();
}

function upThumbGladtookClick(obj){
      document.formg.gladtook.value = 2;
      document.formg.submit();
}

function downThumbDifficultClick(obj){
	  var num = 1;
      document.formd.difficult.value = num;
      document.formd.submit();
}

function upThumbDifficultClick(obj){
	  var num=2;
      document.formd.difficult.value = num;
      document.formd.submit();
}

function thumbHeavyworkloadClick(obj){
	  var id = obj.id;
      var index = id.indexOf('_');
      var num = id.substring(index+1, id.length);
      document.formh.heavyworkload.value = num;
      document.formh.submit();
}

function thumbInterestingClick(obj){
	  var id = obj.id;
      var index = id.indexOf('_');
      var num = id.substring(index+1, id.length);
      document.formi.interesting.value = num;
      document.formi.submit();
}


	
</script>
{%endif%}

<script type="text/javascript">

function lightUP1(index) {
	  
		var index = {{rating}};
	  
      for (i=1; i<6; i++) {
			
            var string = "star_"+i;
            var element = document.getElementById(string);
			
            if (i<= index) {
                  element.src = "/media/images/redStar.png";
            } 
			
			else {
                  element.src = "/media/images/grayStar1.png";
            }
			
			
      }

}

lightUP1({{rating}})

</script>


{%endblock%}